home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 06 - 1990 / 06.01 Jan 90 / DLL Source Code / SampEIIE.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-08-27  |  2.3 KB  |  81 lines  |  [TEXT/MPS ]

  1. /************************************************/
  2. /*                  Sample DLL's                */
  3. /*       Copyright © Vincent Parsons 1989.      */
  4. /************************************************/
  5. /*    DLL code for MPW C 3.0 or THINK C 4.0     */
  6. /*       with Excel for the Macintosh 2.2       */
  7. /*             and Microsoft C 5.1              */
  8. /*          with Excel for Windows 2.1          */
  9. /************************************************/
  10. /* SampEIIE is an example of two data type I    */
  11. /* inputs and one data type E output.  The      */
  12. /* output is the quotient of the two inputs.    */
  13. /* A type E parameter is used to reserve space  */
  14. /* for the returned value.                      */
  15. /************************************************/
  16. /*   =REGISTER("SampDLLs","SampEIIE","EIIE")    */
  17. /*   for both the Mac and the PC.               */
  18. /************************************************/
  19. /* 
  20.    A type E parameter is used to reserve storage
  21.    space in an Excel data buffer for use by the
  22.    DLL.  No data is actually passed as type E.
  23.    
  24.    The function type is pascal double64 * on the 
  25.    Mac and double64 far * far pascal on the PC.
  26.    
  27.    On the Mac the returned value is d1 (a pointer 
  28.    to the double64 result) and the answer has 
  29.    been stored in the Excel buffer reserved by 
  30.    the input variable.
  31.    
  32.    On the PC the returned value is d1 (a double64
  33.    result) and the answer has been stored in the 
  34.    Excel buffer reserved by the input variable.
  35.    
  36.    This was done so the REGISTER command is the 
  37.    same in the PC and the Mac.
  38. */
  39. /************************************************/
  40.  
  41. #include "DLL.h"
  42.  
  43. #if applec
  44. #include <Types.h>
  45.  
  46. #elif MSDOS
  47. #include <windows.h>
  48.  
  49. #endif
  50.  
  51. #if THINK_C
  52. pascal double64 * main(short i1, short i2, double64 * d1);    /* prototype */
  53.  
  54. pascal double64 * main(i1, i2, d1)
  55. short i1;
  56. short i2;
  57. double64 * d1;
  58.  
  59. #elif applec
  60. pascal double64 * SampEIIE(short i1, short i2, double64 * d1)
  61.  
  62. #elif MSDOS
  63. double64 far pascal SampEIIE(short i1, short i2, double64 * d1)
  64. #endif
  65. {
  66.     double64 answer;
  67.     
  68.     /* Returned parameter is the quotient of the two inputs */
  69.     answer = (double64)i1/(double64)i2;
  70.     *d1 = answer;    /* Store value in Excel data buffer */
  71.     
  72. #if applec | THINK_C
  73.     return ( d1 );
  74. #elif MSDOS
  75.     return ( (double64) *d1 );
  76. #endif
  77. }
  78.  
  79. /************************************************/
  80.  
  81.